/*
 * auimenubar.h
 *
 *  Created on: 2012-7-27
 *      Author: Yangde
 */

#ifndef AUIMENUBAR_H_
#define AUIMENUBAR_H_

#include "wx/defs.h"
#include "wx/control.h"
#include "wx/sizer.h"
#include "wx/list.h"


class auiMenu;
WX_DECLARE_OBJARRAY(auiMenu, auiMenuArray);
class auiMenuBar : public wxControl
{
public:
	auiMenuBar(wxWindow* parent,
	                 wxWindowID id = -1,
	                 const wxPoint& position = wxDefaultPosition,
	                 const wxSize& size = wxDefaultSize,
	                 long style = 0);
	~auiMenuBar(){}
	bool Append( auiMenu *menu, const wxString &title );
	bool Realize();

	bool SetFont(const wxFont& font);

	void ProcessMouseMove(const wxPoint& pt);
	void ProcessLeftDown(const wxPoint& pt);

	void ProcessSysMsg(WXMSG *msg);

	wxPoint GetPopupPoint(int index);
	void ReSet();

    int GetItemHeight() const;
    int FindMenuByPosition(const wxPoint& pt);
    void ClickItem(int itemno);
	wxFrame* m_frame;

private:
	auiMenuArray menubar_menus;
	wxBoxSizer* menubar_sizer;
	wxFont menubar_font;
	wxFont menubar_font_u;

	int active_menu;
	bool is_show_menu;
	int last_show_menu;
	bool reset_flag;


	int r_padding;
	int l_padding;
	int t_padding;
	int b_padding;

	int r_margins;
	int l_margins;
	int t_margins;
	int b_margins;
	int font_height;



protected: // handlers

    void OnSize(wxSizeEvent& evt){Refresh();}
    void OnIdle(wxIdleEvent& evt){}
    void OnPaint(wxPaintEvent& evt);
    void OnEraseBackground(wxEraseEvent& evt){}
    void OnLeftDown(wxMouseEvent& evt);
    void OnLeftUp(wxMouseEvent& evt){}
    void OnRightDown(wxMouseEvent& evt){}
    void OnRightUp(wxMouseEvent& evt){}
    void OnMiddleDown(wxMouseEvent& evt){}
    void OnMiddleUp(wxMouseEvent& evt){}
    void OnMotion(wxMouseEvent& evt);
    void OnLeaveWindow(wxMouseEvent& evt);
    void OnCaptureLost(wxMouseCaptureLostEvent& evt){}
    void OnSetCursor(wxSetCursorEvent& evt){}
    void OnKillFocus(wxFocusEvent& event);
    void OnKeyDown(wxKeyEvent& event);
    void DoSetSize(int x,
                                 int y,
                                 int width,
                                 int height,
                                 int sizeFlags);


    void GiveAwayFocus();
    void RefreshItem(size_t pos);
    wxRect GetItemRect(size_t pos) const;

    int GetItemWidth(size_t pos) const;
private:

    DECLARE_EVENT_TABLE()
    DECLARE_CLASS(auiMenuBar)
};

#endif /* AUIMENUBAR_H_ */
